package com.thenmorethings.dao.impl;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.thenmorethings.dao.AdminDao;
import com.thenmorethings.entity.Admin;

public class AdminDaoImpl implements AdminDao{

	
	SessionFactory sessionFactory;
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
	
	@Override
	public Admin findByAdmin(Admin admin) {
		Session session = sessionFactory.getCurrentSession();
		
		Admin ad = (Admin)session.createQuery("from Admin where userName=? and pwd=?")
		.setString(0, admin.getUserName())
		.setString(1, admin.getPwd()).uniqueResult();
		
		return ad;
		
	}

	
}
